from django.db import models
from django.core.exceptions import ObjectDoesNotExist

from game.encounter.models import engagedPlayer
from game.common.logger import logger

# Create your models here.
class profile(models.Model):
    user = models.OneToOneField('auth.user')
    group = models.ForeignKey('monster.group')
    
    def isEngaged(self):
        logger.debug("checking to see if user is engaged")
        try:
            isEngaged = engagedPlayer.objects.get(profile=self)
            logger.debug("User is in combat")
            return True
        except ObjectDoesNotExist:
            logger.debug("User is not in combat")
            return False